<template>
  <div class="app-container">
    <div class="video-box">
      <video-player
        class="video-player"
        id="videoDiv"
        ref="videoPlayer"
        :playsinline="true"
        :options="playerOptions"
        @play="onPlayerPlay($event)"
        @pause="onPlayerPause($event)"
        @ended="onPlayerEnded($event)"
        @playing="onPlayerPlaying($event)"
        ><span>233</span></video-player
      >
    </div>
  </div>
</template>

<script>
export default {
  name: "videoList",
  data() {
    return {
      playerOptions: {
        playbackRates: [0.5, 1.0, 1.5, 2.0],
        autoplay: true,
        muted: false,
        loop: false,
        preload: "auto",
        language: "zh-CN",
        aspectRatio: "16:9",
        fluid: true,
        sources: [
          {
            type: "video/mp4",
            src: "",
          },
        ],
        poster: "", // 封面地址
        width: document.documentElement.clientWidth,
        notSupportedMessage: "此视频暂无法播放，请稍后再试", //允许覆盖Video.js无法播放媒体源时显示的默认信息。
        controlBar: {
          timeDivider: true, // 当前时间和持续时间的分隔符
          durationDisplay: true, // 显示持续时间
          remainingTimeDisplay: true, // 是否显示剩余时间功能
          fullscreenToggle: true, // 是否显示全屏按钮
        },
      },
      videoUrl: "",
    };
  },

  //发请求一般情况下，我们都是在mounted去发，但是也可以在created内部去发
  created() {
    this.videoUrl = this.$route.query.url;
    console.log("this.videoUrl", this.$route);
    this.playVideo(this.videoUrl);
  },

  methods: {
    playVideo(url) {
      console.log("playVideo", url);
      this.playerOptions.sources[0].src = url;
    },
    // 播放的回调
    onPlayerPlay(e) {
      this.isplay = true;
    },
    // 暂停的回调
    onPlayerPause(e) {
      this.isplay = false;
    },
    // 结束的回调
    onPlayerEnded(e) {
      this.isplay = false;
    },
    // 播放中回调
    onPlayerPlaying(e) {
      this.isplay = true;
    },
  },
  computed: {},
};
</script>

<style lang="scss" scoped>
.video-box {
  width: 100%;
  position: relative;
}

/deep/.video-js .vjs-big-play-button {
  width: 88px !important;
  height: 88px !important;
  border-radius: 50% !important;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  border: 0;
  font-size: 56px;
  object-fit: cover;
}

/deep/ .vjs-error .vjs-error-display::before {
  display: none;
}

// /deep/ .vjs-modal-dialog-content {
//   display: none;
// }

// /deep/.video-js .vjs-control-bar {
//   height: 58px;
//   line-height: 58px;
//   background: rgba(0, 0, 0, 0.24) !important;
//   // background: #ac8282;
// }

// /deep/.vjs-button>.vjs-icon-placeholder:before {
//   font-size: 40px;
// }

// /deep/.video-js .vjs-control {
//   font-size: 22px;
//   line-height: 58px;
// }

// /deep/.vjs-playback-rate .vjs-playback-rate-value {
//   line-height: 58px;
// }

// /deep/.vjs-button>.vjs-icon-placeholder:before {
//   line-height: 60px;
// }

// /deep/.vjs-remaining-time-display {
//   font-size: 24px;
// }

// /deep/.video-js .vjs-big-play-button {
//   background-color: rgba(0, 0, 0, 0.5);
// }

// /deep/.video-js .vjs-slider {
//   background-color: rgba(255, 255, 255, 0.5);
// }

// // 视频封面
// /deep/.video-js .vjs-poster {
//   background-size: cover !important;
// }
</style>
